package ru.chaykin.primitives;

public class Point {
	public static final int X_ID = 0;
	public static final int Y_ID = 1;
	
	public static final float z = 0;
	
	private float x;
	private float y;
	
	public Point(float x, float y) {
		this.x=x;
		this.y=y;
	}
	
	public Point(float[] p) {
		x=p[0];
		y=p[1];
	}

	public static float distance(Point p1, Point p2) {
		return (float) Math.sqrt(Math.pow(p1.getx() - p2.getx(), 2) + Math.pow(p1.gety() - p2.gety(), 2));
	}
	
	public static float distance(float x0, float y0, float x1, float y1) {
		return (float) Math.sqrt(Math.pow(x0 - x1, 2) + Math.pow(y0 - y1, 2));
	}
	
	public static float distance(float[] pnts) {
		return (float) Math.sqrt(Math.pow(pnts[0] - pnts[2], 2) + Math.pow(pnts[1] - pnts[3], 2));
	}
	
	public float getx() {
		return x;
	}
	
	public float gety() {
		return y;
	}
	
	public float getCoord(int id) {
		if (id==X_ID)
			return x;
		return y;
	}
}
